import { FormProps } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table';
import { companyTreeData } from '/@/api/sys/company';

export const useConfig = (t: (key: string) => string) => {
  const searchForm: FormProps = {
    baseColProps: { lg: 6, md: 8 },
    labelWidth: 90,
    schemas: [
      {
        label: t('公司'),
        field: 'companyCode',
        fieldLabel: 'companyName',
        component: 'TreeSelect',
        componentProps: {
          api: companyTreeData,
          allowClear: true,
          immediate: true,
          onChange: () => {},
        },
      },
      {
        label: t('单据编号'),
        field: 'fbillno',
        component: 'Input',
      },
      {
        label: t('类型'),
        field: 'busType',
        component: 'Select',
        componentProps: {
          dictType: 'wh_transferorder_bus_type',
          allowClear: true,
        },
      },
      {
        label: t('日期'),
        field: 'fdate',
        component: 'RangePicker',
        componentProps: {
          format: 'YYYY-MM-DD',
          // showTime: { format: 'HH:mm' },
        },
      },
      // {
      //   label: t('日期止'),
      //   field: 'fdate_lte',
      //   component: 'DatePicker',
      //   componentProps: {
      //     format: 'YYYY-MM-DD HH:mm',
      //     showTime: { format: 'HH:mm' },
      //   },
      // },
      {
        label: t('备注'),
        field: 'fexplanation',
        component: 'Input',
      },
      {
        label: t('制单人'),
        field: 'fbiller',
        component: 'Input',
      },
      // {
      //   label: t('状态'),
      //   field: 'status',
      //   component: 'Select',
      //   componentProps: {
      //     dictType: 'sys_search_status',
      //     allowClear: true,
      //     onChange: () => {},
      //   },
      // },
      {
        label: t('创建日期'),
        field: 'createDate',
        component: 'RangePicker',
        componentProps: {
          format: 'YYYY-MM-DD',
          // showTime: { format: 'HH:mm' },
        },
      },
      // {
      //   label: t('创建日期止'),
      //   field: 'createDate_lte',
      //   component: 'DatePicker',
      //   componentProps: {
      //     format: 'YYYY-MM-DD HH:mm',
      //     showTime: { format: 'HH:mm' },
      //   },
      // },
      {
        label: t('备注'),
        field: 'remarks',
        component: 'Input',
      },
      // {
      //   label: t('总数'),
      //   field: 'iqty',
      //   component: 'Input',
      // },
      {
        label: t('来源标识'),
        field: 'sourceFlag',
        component: 'Select',
        componentProps: {
          dictType: 'bas_source_type',
          allowClear: true,
        },
      },
      {
        label: t('公司编码'),
        field: 'companyCode',
        component: 'Input',
      },
      {
        label: t('公司名称'),
        field: 'companyName',
        component: 'Input',
      },
      {
        label: t('是否推送'),
        field: 'bsend',
        component: 'Select',
        componentProps: {
          dictType: 'sys_yes_no',
          allowClear: true,
        },
      },
    ],
    fieldMapToTime: [
      ['fdate', ['fdate_gte', 'fdate_lte']],
      ['createDate', ['createDate_gte', 'createDate_lte']],
    ],
  };

  const searchFormDetail: FormProps = {
    baseColProps: { lg: 6, md: 8 },
    labelWidth: 90,
    schemas: [
      {
        label: t('公司'),
        field: 'hid.companyCode',
        fieldLabel: 'hid.companyName',
        component: 'TreeSelect',
        componentProps: {
          api: companyTreeData,
          allowClear: true,
          immediate: true,
          onChange: () => {},
        },
      },
      {
        label: t('单据编号'),
        field: 'hid.fbillno',
        component: 'Input',
      },
      {
        label: t('类型'),
        field: 'hid.busType',
        component: 'Select',
        componentProps: {
          dictType: 'wh_transferorder_bus_type',
          allowClear: true,
        },
      },
      {
        label: t('日期'),
        field: 'hid.fdate',
        component: 'RangePicker',
        componentProps: {
          format: 'YYYY-MM-DD',
          // showTime: { format: 'HH:mm' },
        },
      },
      {
        label: t('备注'),
        field: 'hid.fexplanation',
        component: 'Input',
      },
      {
        label: t('制单人'),
        field: 'hid.fbiller',
        component: 'Input',
      },
      // {
      //   label: t('状态'),
      //   field: 'status',
      //   component: 'Select',
      //   componentProps: {
      //     dictType: 'sys_search_status',
      //     allowClear: true,
      //     onChange: () => {},
      //   },
      // },
      {
        label: t('创建日期'),
        field: 'hid.createDate',
        component: 'RangePicker',
        componentProps: {
          format: 'YYYY-MM-DD',
          // showTime: { format: 'HH:mm' },
        },
      },
      // {
      //   label: t('创建日期止'),
      //   field: 'createDate_lte',
      //   component: 'DatePicker',
      //   componentProps: {
      //     format: 'YYYY-MM-DD HH:mm',
      //     showTime: { format: 'HH:mm' },
      //   },
      // },
      {
        label: t('备注'),
        field: 'hid.remarks',
        component: 'Input',
      },
      // {
      //   label: t('总数'),
      //   field: 'iqty',
      //   component: 'Input',
      // },
      {
        label: t('来源标识'),
        field: 'hid.sourceFlag',
        component: 'Select',
        componentProps: {
          dictType: 'bas_source_type',
          allowClear: true,
        },
      },
      // {
      //   label: t('公司编码'),
      //   field: 'hid.companyCode',
      //   component: 'Input',
      // },
      // {
      //   label: t('公司名称'),
      //   field: 'hid.companyName',
      //   component: 'Input',
      // },
      {
        label: t('是否推送'),
        field: 'hid.bsend',
        component: 'Select',
        componentProps: {
          dictType: 'sys_yes_no',
          allowClear: true,
        },
      },
    ],
    fieldMapToTime: [
      ['hid.fdate', ['hid.fdate_gte', 'hid.fdate_lte']],
      ['hid.createDate', ['hid.createDate_gte', 'hid.createDate_lte']],
    ],
  };

  const tableColumns: BasicColumn[] = [
    {
      title: t('单据编号'),
      dataIndex: 'fbillno',
      key: 'a.fbillno',
      sorter: true,
      width: 130,
      align: 'left',
      slot: 'firstColumn',
    },
    {
      title: t('类型'),
      dataIndex: 'busType',
      key: 'a.busType',
      sorter: true,
      width: 80,
      align: 'left',
      dictType: 'wh_transferorder_bus_type',
    },
    {
      title: t('是否推送'),
      dataIndex: 'bsend',
      key: 'a.bsend',
      sorter: true,
      width: 100,
      align: 'left',
      dictType: 'sys_yes_no',
    },
    {
      title: t('状态'),
      dataIndex: 'rkStatus',
      key: 'a.rk_status',
      sorter: true,
      width: 100,
      align: 'left',
      dictType: 'wh_transferorder_status',
    },
    {
      title: t('日期'),
      dataIndex: 'fdate',
      key: 'a.fdate',
      sorter: true,
      width: 130,
      align: 'center',
    },
    {
      title: t('备注'),
      dataIndex: 'fexplanation',
      key: 'a.fexplanation',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('制单人'),
      dataIndex: 'fbiller',
      key: 'a.fbiller',
      sorter: true,
      width: 100,
      align: 'left',
    },
    {
      title: t('创建日期'),
      dataIndex: 'createDate',
      key: 'a.create_date',
      sorter: true,
      width: 130,
      align: 'center',
    },
    {
      title: t('更新日期'),
      dataIndex: 'updateDate',
      key: 'a.update_date',
      sorter: true,
      width: 130,
      align: 'center',
    },
    {
      title: t('备注'),
      dataIndex: 'remarks',
      key: 'a.remarks',
      sorter: true,
      width: 130,
      align: 'left',
    },
    // {
    //   title: t('总数'),
    //   dataIndex: 'iqty',
    //   key: 'a.iqty',
    //   sorter: true,
    //   width: 130,
    //   align: 'right',
    // },
    {
      title: t('来源标识'),
      dataIndex: 'sourceFlag',
      key: 'a.source_flag',
      sorter: true,
      width: 130,
      dictType: 'bas_source_type',
    },
    {
      title: t('公司编码'),
      dataIndex: 'companyCode',
      key: 'a.company_code',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('公司名称'),
      dataIndex: 'companyName',
      key: 'a.company_name',
      sorter: true,
      width: 130,
      align: 'left',
    },
  ];

  const tableColumnsDetail: BasicColumn[] = [
    {
      title: t('单据编号'),
      dataIndex: 'hid.fbillno',
      key: 'hid.fbillno',
      sorter: true,
      width: 130,
      align: 'left',
      slot: 'firstColumn',
    },
    {
      title: t('类型'),
      dataIndex: 'hid.busType',
      key: 'hid.bus_type',
      sorter: true,
      width: 80,
      align: 'left',
      dictType: 'wh_transferorder_bus_type',
    },
    {
      title: t('是否推送'),
      dataIndex: 'hid.bsend',
      key: 'hid.bsend',
      sorter: true,
      width: 100,
      align: 'left',
      dictType: 'sys_yes_no',
    },
    {
      title: t('状态'),
      dataIndex: 'hid.rkStatus',
      key: 'hid.rk_status',
      sorter: true,
      width: 80,
      align: 'left',
      dictType: 'wh_transferorder_status',
    },
    {
      title: t('日期'),
      dataIndex: 'hid.fdate',
      key: 'hid.fdate',
      sorter: true,
      width: 130,
      align: 'center',
    },
    {
      title: t('备注'),
      dataIndex: 'hid.fexplanation',
      key: 'hid.fexplanation',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('制单人'),
      dataIndex: 'hid.fbiller',
      key: 'hid.fbiller',
      sorter: true,
      width: 100,
      align: 'left',
    },
    {
      title: t('创建日期'),
      dataIndex: 'hid.createDate',
      key: 'hid.create_date',
      sorter: true,
      width: 130,
      align: 'center',
    },
    {
      title: t('更新日期'),
      dataIndex: 'hid.updateDate',
      key: 'hid.update_date',
      sorter: true,
      width: 130,
      align: 'center',
    },
    {
      title: t('备注'),
      dataIndex: 'hid.remarks',
      key: 'hid.remarks',
      sorter: true,
      width: 130,
      align: 'left',
    },
    // {
    //   title: t('总数'),
    //   dataIndex: 'iqty',
    //   key: 'a.iqty',
    //   sorter: true,
    //   width: 130,
    //   align: 'right',
    // },
    {
      title: t('来源标识'),
      dataIndex: 'hid.sourceFlag',
      key: 'hid.source_flag',
      sorter: true,
      width: 130,
      dictType: 'bas_source_type',
    },
    {
      title: t('公司编码'),
      dataIndex: 'hid.companyCode',
      key: 'hid.company_code',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('公司名称'),
      dataIndex: 'hid.companyName',
      key: 'hid.company_name',
      sorter: true,
      width: 130,
      align: 'left',
    },

    {
      title: t('物料代码'),
      dataIndex: 'basInv.viewCode',
      key: 'a.view_code',
      width: 130,
      // sorter: true,
      align: 'left',
    },
    {
      title: t('物料名称'),
      dataIndex: 'fitemname',
      key: 'a.fitemname',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('计划调拨数量'),
      dataIndex: 'fplanqty',
      width: 130,
      align: 'right',
      key: 'a.fplanqty',
      sorter: true,
      showSummary: true,
    },
    {
      title: t('实际调拨数量'),
      dataIndex: 'frealqty',
      width: 130,
      align: 'right',
      key: 'a.frealqty',
      sorter: true,
      showSummary: true,
    },
    {
      title: t('调出仓库编码'),
      dataIndex: 'fscstockno',
      width: 130,
      align: 'left',
      sorter: true,
      key: 'a.fscstockno',
    },
    {
      title: t('调出仓库名称'),
      dataIndex: 'fscstockname',
      width: 130,
      align: 'left',
      sorter: true,
      key: 'a.fscstockname',
    },
    {
      title: t('调入仓库编码'),
      dataIndex: 'fdcstockno',
      width: 130,
      align: 'left',
      sorter: true,
      key: 'a.fdcstockno',
    },
    {
      title: t('调入仓库编码'),
      dataIndex: 'fdcstockname',
      width: 130,
      align: 'left',
      sorter: true,
      key: 'a.fdcstockname',
    },
    {
      title: t('备注'),
      dataIndex: 'fremarks',
      width: 130,
      align: 'left',
      sorter: true,
      key: 'a.fremarks',
    },
    // {
    //   title: t('状态'),
    //   dataIndex: 'rkStatus',
    //   width: 100,
    //   align: 'left',
    //   dictType: 'wms_rd10_status',
    //   key: 'a.rk_status',
    //   sorter: true,
    // },
    {
      title: t('累计上架数量'),
      dataIndex: 'sumRkQty',
      width: 130,
      align: 'right',
      sorter: true,
      key: 'a.sum_rk_qty',
      showSummary: true,
    },
    {
      title: t('累计下架数量'),
      dataIndex: 'sumCkQty',
      width: 130,
      align: 'right',
      sorter: true,
      key: 'a.sum_ck_qty',
      showSummary: true,
    },
    {
      title: t('形象刊'),
      dataIndex: 'freeVO.cfree1',
      width: 130,
      align: 'left',
    },
  ];

  return {
    searchForm,
    tableColumns,
    tableColumnsDetail,
    searchFormDetail,
  };
};
